package com.yc.demo;

import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.ViewResolver;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;

import javax.servlet.Servlet;

@Configuration
@ComponentScan("com.yc.demo")
// 条件1: 类路径中必须有 Servlet.class 和 DispatcherServlet
@ConditionalOnClass({Servlet.class,DispatcherServlet.class})
//// 条件2: IOC容器中必须包含 ViewResolver 对象
//@ConditionalOnBean(ThymeleafViewResolver.class)
// 条件3: 环境参数必须包含 demo.enable: true
@ConditionalOnProperty(prefix = "demo", value = "enable")
public class DemoStarterAutoConfiguration {

}
